init = function(){
	console.log('HALLO!');
}

doRequest = function(){
   var params = {};
   params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
   params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
   var url = "http://<?php echo $basehost?>/api.php/user/oauth";
   gadgets.io.makeRequest(url, response, params);
}

function response(ret) {
   
   console.log(ret.data);
 
   var html = [ ret.data.validated, "<br />",
     "oauth_consumer_key: ", ret.data.query.oauth_consumer_key, "<br />",
     "oauth_nonce: ", ret.data.query.oauth_nonce, "<br />",
     "oauth_signature: ", ret.data.query.oauth_signature, "<br />",
     "oauth_signature_method: ", ret.data.query.oauth_signature_method, "<br />",
     "oauth_timestamp: ", ret.data.query.oauth_timestamp, "<br />",
     "oauth_token: ", ret.data.query.oauth_token, "<br />",
     "opensocial_appid: ", ret.data.query.opensocial_appid, "<br />",
     "opensocial_ownerid: ", ret.data.query.opensocial_ownerid, "<br />",
     "xoauth_signature_publickey: ", ret.data.query.xoauth_signature_publickey ].join("");
 
	document.getElementById('debug').innerHTML = html;
 
};



gadgets.util.registerOnLoadHandler(init);